﻿using System.Data;
using System.Data.OracleClient;
using System.Windows.Data;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class VAMSTAMM
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {
            #region
            #endregion
            switch (app.company)
            {
                case "YGR":
                case "SXN":
                case "TST":
                case "UBT":
                default:
                    #region
                    dwReturn["AMMANDANT"] = "00";
                    dwReturn["AMNRKRS"] = "M ";
                    dwReturn["AMLFDNR"] = "0046";
                    dwReturn["AMPOS"] = "00";
                    dwReturn["AMBEZ"] = "                                        ";
                    dwReturn["AMWERK"] = "   ";
                    dwReturn["AMABT"] = "   ";
                    dwReturn["AMLIEFNR"] = "        ";
                    dwReturn["AMHERST"] = "SP                  ";
                    dwReturn["AMTYP"] = "XS      ";
                    dwReturn["AMART"] = "XS      ";
                    dwReturn["AMKSTKRS"] = "  ";
                    dwReturn["AMKST"] = "0400";
                    dwReturn["AMPKSTKRS"] = "  ";
                    dwReturn["AMPKST"] = "0400";
                    dwReturn["AMTERMNR"] = "        ";
                    dwReturn["AMBDEMA"] = "46      ";
                    dwReturn["AMSUBSYS"] = "  ";
                    dwReturn["AMBDEMA2"] = "        ";
                    dwReturn["AMSUBSYS2"] = "  ";
                    dwReturn["AMLO"] = "01";
                    dwReturn["AMLB"] = "XS";
                    dwReturn["AMLPLATZ"] = "A       ";
                    dwReturn["AMINVNR"] = "      ";
                    dwReturn["AMINVPOS"] = "  ";
                    dwReturn["AMBELKZ"] = "N";
                    dwReturn["AMAUFKRS"] = "  ";
                    dwReturn["AMAUFLFD"] = "000000";
                    dwReturn["AMAUFPOS"] = "000";
                    dwReturn["AMVERFKZ"] = "K";
                    dwReturn["AMSTAKZ"] = "A";
                    dwReturn["AMSTDVAR"] = "N";
                    dwReturn["AMFAKTOR"] = "1";
                    dwReturn["AMABREITEV"] = "0";
                    dwReturn["AMABREITEB"] = "0";
                    dwReturn["AMAGRVON"] = "0";
                    dwReturn["AMAGRBIS"] = "0";
                    dwReturn["AMAUFTRVON"] = "0";
                    dwReturn["AMAUFTRBIS"] = "0";
                    dwReturn["AMME"] = "7";
                    dwReturn["AMNUTZEF"] = "100";
                    dwReturn["AMSTKVON"] = "0";
                    dwReturn["AMSTKBIS"] = "420";
                    dwReturn["AMSTKDIVI"] = "0";
                    dwReturn["AMFADGBIS"] = "0";
                    dwReturn["AMSFTBIS"] = "0";
                    dwReturn["AMSDMBIS"] = "0";
                    dwReturn["AMFLANSCH"] = "  ";
                    dwReturn["AMBRTBM"] = "0";
                    dwReturn["AMSCHAUR"] = " ";
                    dwReturn["AMWSOUT"] = "    ";
                    dwReturn["AMWSOKP"] = "0";
                    dwReturn["AMWSIN"] = "    ";
                    dwReturn["AMEHHF"] = "0";
                    dwReturn["AMEHHR"] = "0";
                    dwReturn["AMEHHA"] = "0";
                    dwReturn["AMWZL1"] = "0";
                    dwReturn["AMWZLD1"] = "0";
                    dwReturn["AMWZL2"] = "0";
                    dwReturn["AMWZLD2"] = "0";
                    dwReturn["AMWZL3"] = "0";
                    dwReturn["AMWZLD3"] = "0";
                    dwReturn["AMWZL4"] = "0";
                    dwReturn["AMWZLD4"] = "0";
                    dwReturn["AMWZL5"] = "0";
                    dwReturn["AMWZLD5"] = "0";
                    dwReturn["AMWZL6"] = "0";
                    dwReturn["AMWZLD6"] = "0";
                    dwReturn["AMWZL7"] = "0";
                    dwReturn["AMWZLD7"] = "0";
                    dwReturn["AMWZL8"] = "0";
                    dwReturn["AMWZLD8"] = "0";
                    dwReturn["AMWZL9"] = "0";
                    dwReturn["AMWZLD9"] = "0";
                    dwReturn["AMWZL10"] = "0";
                    dwReturn["AMWZLD10"] = "0";
                    dwReturn["AMZLTYPE"] = "   ";
                    dwReturn["AMZLE"] = "0";
                    dwReturn["AMZLMMIE"] = "0";
                    dwReturn["AMZLDATE"] = "0";
                    dwReturn["AMZLZEITE"] = "0";
                    dwReturn["AMZLSCHE"] = "0";
                    dwReturn["AMZLTYPA"] = "   ";
                    dwReturn["AMZLA"] = "0";
                    dwReturn["AMZLMMIA"] = "0";
                    dwReturn["AMZLDATA"] = "0";
                    dwReturn["AMZLZEITA"] = "0";
                    dwReturn["AMZLSCHA"] = "0";
                    dwReturn["AMZEFEA"] = "0";
                    dwReturn["AMZMAXBA"] = "0";
                    dwReturn["AMWSCHLA"] = "          ";
                    dwReturn["AMANZPLA"] = "00";
                    dwReturn["AMMSTILLST"] = "0";
                    dwReturn["AMBDECODE"] = "    ";
                    dwReturn["AMBDEAUFB"] = "  ";
                    dwReturn["AMUEORT1"] = "  ";
                    dwReturn["AMUEORT2"] = "  ";
                    dwReturn["AMUEORT3"] = "  ";
                    dwReturn["AMUEORT4"] = "  ";
                    dwReturn["AMUEORTZEILE"] = "00";
                    dwReturn["AMUEORTSPALTE"] = "00";
                    dwReturn["AMCLO"] = "  ";
                    dwReturn["AMCLB"] = "  ";
                    dwReturn["AMCLP"] = "        ";
                    dwReturn["AMDOSIER"] = " ";
                    dwReturn["AMSTDAGRVON"] = "000000000";
                    dwReturn["AMSTDAGRBIS"] = "000000000";
                    dwReturn["AMSPGROE"] = "0000";
                    dwReturn["AMINOUT"] = " ";
                    dwReturn["AMGEBNR"] = "        ";
                    dwReturn["AMKUNDNR"] = "        ";
                    dwReturn["AMSTKNR"] = "            ";
                    dwReturn["AMTSTKNR"] = "            ";
                    dwReturn["AMZTR"] = " ";
                    dwReturn["AMFILLER"] = "                                                                                                         ";
                    dwReturn["AMAENDZL"] = "1";
                    dwReturn["AMAENDBEN"] = "        ";
                    dwReturn["AMAENDDAT"] = "0";
                    dwReturn["AMNEUBEN"] = "        ";
                    dwReturn["AMNEUDAT"] = "0";
                    #endregion
                    break;
            }
        }

        public void InserAMSTAMM(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            //APZMANDANT APZART APZVAR APZANRKRS APZALFDNR APZSTUFE

            dwData["AMNEUBEN"] =app.User;
            dwData["AMNEUDAT"] = date;
            or1 = OracleDB.CreateCommand();
            switch (app.company)
            {
               
                case "YGR":
                case "SXN":
                case "TST":
                case "UBT":
                default:
                    or1.CommandText = "INSERT INTO AMSTAMM ( AMMANDANT,AMNRKRS,AMLFDNR,AMPOS,AMBEZ,AMWERK,AMABT,AMLIEFNR,AMHERST,AMTYP,AMART,AMKSTKRS,AMKST,AMPKSTKRS,AMPKST,AMTERMNR,AMBDEMA,AMSUBSYS,AMBDEMA2,AMSUBSYS2,AMLO,AMLB,AMLPLATZ,AMINVNR,AMINVPOS,AMBELKZ,AMAUFKRS,AMAUFLFD,AMAUFPOS,AMVERFKZ,AMSTAKZ,AMSTDVAR,AMFAKTOR,AMABREITEV,AMABREITEB,AMAGRVON,AMAGRBIS,AMAUFTRVON,AMAUFTRBIS,AMME,AMNUTZEF,AMSTKVON,AMSTKBIS,AMSTKDIVI,AMFADGBIS,AMSFTBIS,AMSDMBIS,AMFLANSCH,AMBRTBM,AMSCHAUR,AMWSOUT,AMWSOKP,AMWSIN,AMEHHF,AMEHHR,AMEHHA,AMWZL1,AMWZLD1,AMWZL2,AMWZLD2,AMWZL3,AMWZLD3,AMWZL4,AMWZLD4,AMWZL5,AMWZLD5,AMWZL6,AMWZLD6,AMWZL7,AMWZLD7,AMWZL8,AMWZLD8,AMWZL9,AMWZLD9,AMWZL10,AMWZLD10,AMZLTYPE,AMZLE,AMZLMMIE,AMZLDATE,AMZLZEITE,AMZLSCHE,AMZLTYPA,AMZLA,AMZLMMIA,AMZLDATA,AMZLZEITA,AMZLSCHA,AMZEFEA,AMZMAXBA,AMWSCHLA,AMANZPLA,AMMSTILLST,AMBDECODE,AMBDEAUFB,AMUEORT1,AMUEORT2,AMUEORT3,AMUEORT4,AMUEORTZEILE,AMUEORTSPALTE,AMCLO,AMCLB,AMCLP,AMDOSIER,AMSTDAGRVON,AMSTDAGRBIS,AMSPGROE,AMINOUT,AMGEBNR,AMKUNDNR,AMSTKNR,AMTSTKNR,AMZTR,AMFILLER,AMAENDZL,AMAENDBEN,AMAENDDAT,AMNEUBEN,AMNEUDAT)"
                    + "SELECT :AMMAND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CLP:,:AMDOSIER:,:AMSTDAGRVON:,:AMSTDAGRBIS:,:AMSPGROE:,:AMINOUT:,:AMGEBNR:,:AMKUNDNR:,:AMSTKNR:,:AMTSTKNR:,:AMZTR:,:AMFILLER:,:AMAENDZL:,:AMAENDBEN:,:AMAENDDAT:,:AMNEUBEN:,:AMNEUDAT:"
                    + " FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM AMSTAMM WHERE AMMANDANT=:AMMANDANT: AND AMNRKRS=:AMNRKRS: AND AMLFDNR=:AMLFDNR:   AND  AMPOS=:AMPOS:  )";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            } 
            Connect2Proxy(or1);
        }
        public void UpdateAMSTAMM(DataRow dwData, int option = 1)
        {
            if (option == 0)
            {
                switch (app.company)
                {
                    case "YGR":
                    default:
                        option = 1;
                        break;
                }
            }
            or1 = OracleDB.CreateCommand();
            switch (option)
            { 
                case 1: UAM01(dwData); break;
                case 2: UAM02(dwData); break;
                default:
                    break;
            }
        }
        public void UAM01(DataRow dwData)
        {
            dwData["AMAENDBEN"] = app.User;
            dwData["AMNEUDAT"] = date;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE AMSTAMM SET AMMANDANT=:AMMANDANT:,AMNRKRS=:AMNRKRS:,AMLFDNR=:AMLFDNR:,AMPOS=:AMPOS:,AMBEZ=:AMBEZ:,AMWERK=:AMWERK:,AMABT=:AMABT:,AMLIEFNR=:AMLIEFNR:,AMHERST=:AMHERST:,AMTYP=:AMTYP:,AMART=:AMART:,AMKSTKRS=:AMKSTKRS:,AMKST=:AMKST:,AMPKSTKRS=:AMPKSTKRS:,AMPKST=:AMPKST:,AMTERMNR=:AMTERMNR:,AMBDEMA=:AMBDEMA:,AMSUBSYS=:AMSUBSYS:,AMBDEMA2=:AMBDEMA2:,AMSUBSYS2=:AMSUBSYS2:,AMLO=:AMLO:,AMLB=:AMLB:,AMLPLATZ=:AMLPLATZ:,AMINVNR=:AMINVNR:,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=:AMZLZEITE:,AMZLSCHE=:AMZLSCHE:,AMZLTYPA=:AMZLTYPA:,AMZLA=:AMZLA:,AMZLMMIA=:AMZLMMIA:,AMZLDATA=:AMZLDATA:,AMZLZEITA=:AMZLZEITA:,AMZLSCHA=:AMZLSCHA:,AMZEFEA=:AMZEFEA:,AMZMAXBA=:AMZMAXBA:,AMWSCHLA=:AMWSCHLA:,AMANZPLA=:AMANZPLA:,AMMSTILLST=:AMMSTILLST:,AMBDECODE=:AMBDECODE:,AMBDEAUFB=:AMBDEAUFB:,AMUEORT1=:AMUEORT1:,AMUEORT2=:AMUEORT2:,AMUEORT3=:AMUEORT3:,AMUEORT4=:AMUEORT4:,AMUEORTZEILE=:AMUEORTZEILE:,AMUEORTSPALTE=:AMUEORTSPALTE:,AMCLO=:AMCLO:,AMCLB=:AMCLB:,AMCLP=:AMCLP:,AMDOSIER=:AMDOSIER:,AMSTDAGRVON=:AMSTDAGRVON:,AMSTDAGRBIS=:AMSTDAGRBIS:,AMSPGROE=:AMSPGROE:,AMINOUT=:AMINOUT:,AMGEBNR=:AMGEBNR:,AMKUNDNR=:AMKUNDNR:,AMSTKNR=:AMSTKNR:,AMTSTKNR=:AMTSTKNR:,AMZTR=:AMZTR:,AMFILLER=:AMFILLER:,AMAENDZL=AMAENDZL+1,AMAENDBEN=:AMAENDBEN:,AMAENDDAT=:AMAENDDAT:,AMNEUBEN=:AMNEUBEN:,AMNEUDAT=:AMNEUDAT:"
                    + " WHERE AMMANDANT=:AMMANDANT: AND  AMNRKRS=:AMNRKRS: AND AMLFDNR=:AMLFDNR: AND AMPOS=:AMPOS: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);

            Connect2Proxy(or1);

        }
        public void UAM02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE AMSTAMM SET AMAUFTRVON=:AMAUFTRVON: ,AMAENDZL=AMAENDZL+1"
                 + " WHERE AMMANDANT=:AMMANDANT: AND  AMNRKRS=:AMNRKRS: AND AMLFDNR=:AMLFDNR: AND AMPOS=:AMPOS: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        } 
        
        public void UAM03(DataRow dwData)
        {
            
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE AMSTAMM SET AMAUFKRS=:AMAUFKRS:, AMAUFLFD=:AMAUFLFD:,AMAUFPOS=:AMAUFPOS:,AMBELKZ=:AMBELKZ:,AMAENDZL=AMAENDZL+1  "
                 + " WHERE AMMANDANT=:AMMANDANT: AND  AMNRKRS=:AMNRKRS: AND AMLFDNR=:AMLFDNR: AND AMPOS=:AMPOS: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void UAM04(DataRow dwData)
        { 
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE AMSTAMM SET AMFILLER=:AMFILLER:  "
                 + " WHERE AMMANDANT=:AMMANDANT: AND  AMNRKRS=:AMNRKRS: AND AMLFDNR=:AMLFDNR: AND AMPOS=:AMPOS: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public DataSet QueryAMSTAMM(DataRow dwData, int option = 1)
        {
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0: SResult = QAM00(dwData); break;
                case 1: SResult = QAM01(dwData); break;
                case 2: SResult = QAM02(dwData); break;
            }
            return SResult;
        }

        public DataSet QAM00(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM AMSTAMM WHERE  ROWNUM<2 ";
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QAM01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT M.*,'m'||RTRIM(AMNRKRS)||'_'||AMLFDNR||'_'||AMPOS AS MACHINEID,RTRIM(AMHERST) AS SMTYP,0 AS JJVALUE,0 AS WD FROM AMSTAMM M "
            + " WHERE AMMANDANT=:AMMANDANT: AND  AMKSTKRS=:AMKSTKRS: AND AMKST=:AMKST: AND AMTYP=:AMTYP: "
            + " ORDER BY AMNRKRS,AMLFDNR,AMPOS ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QAM02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT  AMNRKRS||AMLFDNR||AMPOS AS MACHINEID,AMNRKRS,AMLFDNR,AMPOS,AMBEZ,AMSTKBIS,AMAUFTRVON*0.001 AS AMAUFTRVON,AMAUFTRBIS*0.001 AS AMAUFTRBIS ,AMBDEMA FROM AMSTAMM M "
                    + " WHERE  AMNRKRS||AMLFDNR||AMPOS=:MACHINEID: OR (RTRIM(AMART)||RTRIM(AMBDEMA)=RTRIM(:ABFAGANG:)||RTRIM(:MACHINEID:))"
                    + " ORDER BY AMNRKRS,AMLFDNR,AMPOS ";

            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QAM03(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT  AMNRKRS||AMLFDNR||AMPOS AS MACHINEID,M.* FROM AMSTAMM M "
                    + " WHERE AMMANDANT=:AMMANDANT:"
                    + dwData["AMNRKRS"].ToString()
                    + dwData["AMLFDNR"].ToString()
                    + dwData["AMPOS"].ToString()
                    + dwData["AMKSTKRS"].ToString()
                    + dwData["AMKST"].ToString()
                    + dwData["AMTYP"].ToString()
                    + dwData["AMART"].ToString()
                    
            ;
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QAM04(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT  M.* FROM AMSTAMM M "
                    + " WHERE AMMANDANT=:AMMANDANT: AND AMSTDVAR=:AMSTDVAR:"
                        + dwData["AMNRKRS"].ToString()
                    + dwData["AMLFDNR"].ToString()
                    + dwData["AMPOS"].ToString()
                    + dwData["AMKSTKRS"].ToString()
                    + dwData["AMKST"].ToString()
                    + dwData["AMTYP"].ToString();
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QAM05(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT DISTINCT AMNRKRS||AMLFDNR||AMPOS AS MACHINEID,AMNRKRS,AMLFDNR,AMPOS,AMBEZ,AMKSTKRS,AMKST,AMBDEMA,AMLO,AMLB,AMLPLATZ,AMFILLER FROM AMSTAMM M "
                    + " WHERE   AMMANDANT=:AMMANDANT: "
                    + " ORDER BY AMNRKRS,AMLFDNR,AMPOS ";

            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QAM06(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT DISTINCT AMNRKRS||AMLFDNR||AMPOS AS MACHINEID,AMNRKRS,AMLFDNR,AMPOS,AMBEZ,AMHERST FROM AMSTAMM M "
                    + " WHERE AMMANDANT=:AMMANDANT: AND AMHERST=:AMHERST: "
                    + " ORDER BY AMNRKRS,AMLFDNR,AMPOS ";

            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QAM07(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT DISTINCT AMNRKRS||AMLFDNR||AMPOS AS MACHINEID,AMNRKRS,AMLFDNR,AMPOS,AMBEZ,AMHERST,AMTYP,AMART,AMKSTKRS,AMKST FROM AMSTAMM M "
                    + " WHERE AMMANDANT=:AMMANDANT: AND AMBDEMA=:AMBDEMA: "
                    + " ORDER BY AMNRKRS,AMLFDNR,AMPOS ";

            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QAM08(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT M.* FROM AMSTAMM M "
            + " WHERE AMMANDANT=:AMMANDANT: AND  AMNRKRS=:AMNRKRS: AND AMLFDNR=:AMLFDNR: AND AMPOS=:AMPOS: "
            + " ORDER BY AMNRKRS,AMLFDNR,AMPOS ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void DAM00(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM AMSTAMM "
                 + " WHERE AMMANDANT=:AMMANDANT:  ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }
        public void DAM01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM AMSTAMM "
                 + " WHERE AMMANDANT=:AMMANDANT: AND  AMNRKRS=:AMNRKRS: AND AMLFDNR=:AMLFDNR: AND AMPOS=:AMPOS: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }

        public void DAM02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM AMSTAMM "
                 + " WHERE AMMANDANT=:AMMANDANT: AND  AMNRKRS=:AMNRKRS: AND AMLFDNR=:AMLFDNR: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }
        public void DAM03(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM AMSTAMM "
                 + " WHERE AMMANDANT=:AMMANDANT: AND  AMKSTKRS=:AMKSTKRS: AND AMKST=:AMKST: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void DAMTYP(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM AMSTAMM "
                 + " WHERE AMMANDANT=:AMMANDANT:  AND AMTYP=:AMTYP: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
    }
}
